package com.zeroone.star.cpp.service.impl;

import com.zeroone.star.cpp.service.ISampleService;
import com.zeroone.star.project.dto.PageDTO;
import com.zeroone.star.project.dto.cpp.SampleDTO;
import com.zeroone.star.project.vo.JsonVO;
import lombok.AllArgsConstructor;
import java.util.Map;

/**
 * <p>
 * 员工表 服务实现类
 * </p>
 *
 * @author lyx
 * @since 2024-10-29
 */

@AllArgsConstructor
public class SampleServiceImpl implements ISampleService {

    private Throwable throwable;

    private <T> JsonVO<T> setMessage(JsonVO<T> jsonVO){
        if(throwable.getMessage() != null){
            jsonVO.setMessage(throwable.getMessage());
        }else {
            jsonVO.setMessage(throwable.getClass().getSimpleName());
        }
        return jsonVO;
    }

    @Override
    public JsonVO<PageDTO<SampleDTO>> get(Map<String, Object> query) {
        return setMessage(JsonVO.fail(null));
    }

    @Override
    public JsonVO<Long> post(SampleDTO dto) {
        return setMessage(JsonVO.fail(null));
    }

    @Override
    public JsonVO<Long> put(SampleDTO dto) {
        return setMessage(JsonVO.fail(null));
    }

    @Override
    public JsonVO<Long> delete(Long id) {
        return setMessage(JsonVO.fail(null));
    }
}
